package com.example.inventoryservice.WarehouseQueryDemo;

import java.util.List;

public class WarehouseQueryContext {

    private WarehouseFilterStrategy strategy;

    // 根据条件选择合适的策略
    public void setStrategy(String inventoryOrg) {
        if (inventoryOrg != null && !inventoryOrg.isEmpty()) {
            // 库存组织有值时，使用库存组织过滤策略
            strategy = new InventoryOrgFilterStrategy();
        } else {
            // 库存组织为空时，使用会计主体过滤策略
            strategy = new AccountingEntityFilterStrategy();
        }
    }

    // 执行过滤
    public List<Warehouse> executeFilter(List<Warehouse> allWarehouses, String inventoryOrg, String accountingEntity) {
        return strategy.filter(allWarehouses, inventoryOrg, accountingEntity);
    }
}
